package com.supsi.segreteria.client;

import com.intellij.uiDesigner.core.GridConstraints;
import com.intellij.uiDesigner.core.GridLayoutManager;
import com.intellij.uiDesigner.core.Spacer;

import javax.swing.*;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

/**
 * Created with IntelliJ IDEA.
 * User: cristian
 * Date: 5/26/12
 * Time: 1:43 PM
 * To change this template use File | Settings | File Templates.
 */
public class GUIView implements IGUIObserver {
    private JPanel panel1;
    private JList lstContacts;
    private JButton btnRemoveContact;
    private JButton btnCallContact;
    private JButton btnAddContact;
    private JLabel lbLeftTitle;
    private JPanel jpLeftContent;
    private JLabel lbRightTitle;
    private JTextArea txtChat;
    private JTextField txtMessage;
    private JButton btnSendMessage;
    private JScrollPane jspChat;
    private JPanel jpRightContent;
    private JPanel jpRightCommands;
    private JPanel jpLeftCommands;
    private JButton btnExit;
    private JPanel jpChatCommands;
    private JTextField txtNewName;
    private JTextField txtNewNumber;
    private JPanel jpAddContact;
    private JLabel lbNewNumber;
    private JLabel lbNewName;
    private JScrollPane jspContacts;
    private JButton btnGetMessages;
    private JButton btnCloseCall;
    private JButton btnGetNewMessages;
    private JButton btnClearChatHistory;
    private JButton btnDeleteMessage;
    private JButton btnDelAllMessages;
    private JTextField txtMsgToRemove;
    private final DefaultListModel listModel = new DefaultListModel();

    private int selectedIndex = -1;
    private Configurator conf = Configurator.getInstance();

    /**
     * MVC Model for this GUI
     */
    private GUIModel model = new GUIModel();

    /**
     * Class constructor
     */
    public GUIView() {
        //setup GUI Actions
        setupGUIActions();
        //register as observer for model
        model.addObserver(this);

        model.connectToServer(new Long(conf.getfUserNumber()).toString());

    }

    private void setupGUIActions() {

        //load AddressBook into listModel
        loadAddressBook();
        //set lstContatti new filled model
        lstContacts.setModel(listModel);


        //set button pressed action for btnDeleteAllMessages button
        btnExit.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent evt) {

                //ask model to disconnect from server
                model.disconnectFromServer();
                //exit application
                System.exit(0);
            }
        });

        //set MouseListener for click events on contact list
        // Add a listener for mouse clicks
        lstContacts.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent evt) {
                JList list = (JList) evt.getSource();
                if (evt.getClickCount() == 1 || evt.getClickCount() == 2) {          // Double-click
                    // Get item index
                    selectedIndex = list.locationToIndex(evt.getPoint());
                    txtNewNumber.setText(listModel.get(selectedIndex).toString().split(":")[0]);
                    txtNewName.setText(listModel.get(selectedIndex).toString().split(":")[1]);
                    btnRemoveContact.setEnabled(true);
                    btnCallContact.setEnabled(true);
                }
            }
        });

        //set button pressed action for btnDeleteAllMessages button
        btnDelAllMessages.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent evt) {

                //ask model to delete al messages
                model.deleteAllMessages();

            }
        });

        //set button pressed action for btnDeleteMessages button
        btnDeleteMessage.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent evt) {

                String strMessageNum = txtMsgToRemove.getText();

                if (strMessageNum.trim().length() > 0) {
                    if (conf.isNumber(strMessageNum)) {
                        txtMsgToRemove.setBackground(Color.WHITE);
                        //ask model to delete al messages
                        model.deleteMessage(Integer.parseInt(strMessageNum));
                        txtMsgToRemove.setText("");
                    } else {
                        txtMsgToRemove.setBackground(Color.RED);
                    }
                } else {
                    txtMsgToRemove.setBackground(Color.ORANGE);
                }
            }
        });


        //set button pressed action for btnAddContact button
        btnAddContact.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent evt) {

                String sNewNumber = txtNewNumber.getText();
                String sNewName = txtNewName.getText();


                if (sNewNumber.trim().length() > 0 && sNewName.trim().length() > 0) {
                    //add data to model
                    listModel.add(listModel.size(), sNewNumber + ":" + sNewName);
                    //add data to real addressbook and save it
                    model.addNewContact(Long.parseLong(sNewNumber), sNewName);
                }

            }
        });

        //set button pressed action for btnAddContact button
        btnRemoveContact.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent evt) {

                Long userNumber = Long.parseLong(listModel.get(selectedIndex).toString().split(":")[0]);
                String userName = listModel.get(selectedIndex).toString().split(":")[1];

                //remove entry from contacts list
                listModel.remove(selectedIndex);

                //remove contact from model
                model.removeContact(userNumber, userName);

                btnRemoveContact.setEnabled(false);
                btnCallContact.setEnabled(false);

                txtNewName.setText("");
                txtNewName.setBackground(Color.WHITE);
                txtNewNumber.setText("");
                txtNewNumber.setBackground(Color.WHITE);

                selectedIndex = -1;

            }
        });

        //set button pressed action for btnAddContact button
        btnCallContact.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent evt) {

                //opening  call....

                //adjust GUI enabling right panel and disabling Left Panel
                lstContacts.setEnabled(false);
                btnCallContact.setEnabled(false);
                btnRemoveContact.setEnabled(false);
                btnCallContact.setEnabled(false);
                btnSendMessage.setEnabled(true);
                btnCloseCall.setEnabled(true);
                txtMessage.setEnabled(true);

            }
        });

        //set button pressed action for btnCloseCall button
        btnCloseCall.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent actionEvent) {

                // closing call

                //reenable left GUI components and disable right ones
                lstContacts.setEnabled(true);
                btnCallContact.setEnabled(true);
                btnRemoveContact.setEnabled(true);
                btnCallContact.setEnabled(true);
                btnSendMessage.setEnabled(false);
                btnCloseCall.setEnabled(false);
                txtMessage.setEnabled(false);
                txtMessage.setText("");
            }
        });

        //set button pressed action for btnSendMessage button
        btnSendMessage.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent actionEvent) {

                //retrieving user number
                Long userNumber = Long.parseLong(listModel.get(selectedIndex).toString().split(":")[0]);
                String message = txtMessage.getText();

                if (message.trim().length() > 0) {
                    model.sendMessage(userNumber, message);
                    txtMessage.setText("");
                }

            }
        });

        //set button pressed action for btnGetMessages button
        btnGetMessages.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent actionEvent) {

                //retrieving messages from Model
                model.retrieveMessages();
                //results are notified to observers via update method.

            }
        });

        //set button pressed action for btnGetNewMessages
        btnGetNewMessages.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent actionEvent) {

                //retrieving messages from Model
                model.retrieveNewMessages();
                btnGetNewMessages.setEnabled(false);
                //results are notified to observers via update method.

            }
        });

        //set button pressed action for btnGetNewMessages
        btnClearChatHistory.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent actionEvent) {

                //clearing chat history from Model
                model.clearChatHistory();
                //results are notified to observers via update method.

            }
        });

        // Listen for changes in new number text field
        txtNewNumber.getDocument().addDocumentListener(new DocumentListener() {
            public void changedUpdate(DocumentEvent e) {
                doValidate();
            }

            public void removeUpdate(DocumentEvent e) {
                doValidate();
            }

            public void insertUpdate(DocumentEvent e) {
                doValidate();
            }

            //let's do some input validation
            public void doValidate() {

                String sNewNumber = txtNewNumber.getText().trim();
                String sNewName = txtNewName.getText().trim();

                if (sNewNumber.length() > 0) {
                    if (conf.isNumber(sNewNumber)) {
                        if (Long.parseLong(sNewNumber) >= 0) {
                            if (sNewName.length() > 0) {
                                txtNewNumber.setBackground(Color.WHITE);
                                btnAddContact.setEnabled(true);
                            } else {
                                txtNewNumber.setBackground(Color.WHITE);
                                txtNewName.setBackground(Color.ORANGE);
                                btnAddContact.setEnabled(false);
                            }
                        } else {
                            txtNewNumber.setBackground(Color.RED);
                            btnAddContact.setEnabled(false);
                        }
                    } else {
                        txtNewNumber.setBackground(Color.RED);
                        btnAddContact.setEnabled(false);
                    }
                } else {
                    if (sNewName.length() > 0)
                        txtNewNumber.setBackground(Color.WHITE);
                    else
                        txtNewNumber.setBackground(Color.ORANGE);

                    btnAddContact.setEnabled(false);
                }
            }
        });


        // Listen for changes in new name text field
        txtNewName.getDocument().addDocumentListener(new DocumentListener() {
            public void changedUpdate(DocumentEvent e) {
                doValidate();
            }

            public void removeUpdate(DocumentEvent e) {
                doValidate();
            }

            public void insertUpdate(DocumentEvent e) {
                doValidate();
            }

            //let's do some input validation
            public void doValidate() {

                String sNewName = txtNewName.getText().trim();
                String sNewNumber = txtNewNumber.getText().trim();

                if (sNewName.length() > 0) { //check also if number is filled
                    if (conf.isNumber(sNewNumber)) {
                        txtNewName.setBackground(Color.WHITE);
                        btnAddContact.setEnabled(true);
                    } else {
                        txtNewName.setBackground(Color.WHITE);
                        txtNewNumber.setBackground(Color.ORANGE);
                        btnAddContact.setEnabled(false);
                    }
                } else {
                    if (conf.isNumber(sNewNumber))
                        txtNewName.setBackground(Color.ORANGE);
                    else
                        txtNewName.setBackground(Color.WHITE);

                    btnAddContact.setEnabled(false);
                }
            }
        });

    }

    /**
     * return form panel to be added to a JFrame
     *
     * @return JPanel panel containing form
     */
    public JPanel getContentPanel() {
        return panel1;
    }

    /**
     * load(reload Addressbook within the list
     */
    private void loadAddressBook() {

        Configurator.AddressBook.AddressBookEntry abe[] = model.getAddressBook();
        for (Configurator.AddressBook.AddressBookEntry entry : abe) {
            //set property values
            listModel.addElement(entry.toString().replace("[", "").replace("]", ""));
        }
    }

    @Override
    public void update(GUIModel model) {
        //called every time something in the model is changed

        String newText = model.loadChatHistory();
        //update Chat log field
        txtChat.setText(newText);

        if (newText.endsWith("-->there are new messages for you!\n"))
            btnGetNewMessages.setEnabled(true);

    }


    {
// GUI initializer generated by IntelliJ IDEA GUI Designer
// >>> IMPORTANT!! <<<
// DO NOT EDIT OR ADD ANY CODE HERE!
        $$$setupUI$$$();
    }

    /**
     * Method generated by IntelliJ IDEA GUI Designer
     * >>> IMPORTANT!! <<<
     * DO NOT edit this method OR call it in your code!
     *
     * @noinspection ALL
     */
    private void $$$setupUI$$$() {
        panel1 = new JPanel();
        panel1.setLayout(new GridLayoutManager(1, 1, new Insets(2, 2, 2, 2), -1, -1));
        panel1.setEnabled(false);
        panel1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), null));
        final JSplitPane splitPane1 = new JSplitPane();
        panel1.add(splitPane1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, new Dimension(200, 200), null, 0, false));
        jpLeftContent = new JPanel();
        jpLeftContent.setLayout(new GridLayoutManager(9, 1, new Insets(0, 0, 0, 0), -1, -1));
        splitPane1.setLeftComponent(jpLeftContent);
        lbLeftTitle = new JLabel();
        lbLeftTitle.setEnabled(true);
        lbLeftTitle.setText("Elenco contatti");
        jpLeftContent.add(lbLeftTitle, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
        jpLeftCommands = new JPanel();
        jpLeftCommands.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1));
        jpLeftContent.add(jpLeftCommands, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
        btnAddContact = new JButton();
        btnAddContact.setEnabled(false);
        btnAddContact.setText("+");
        jpLeftCommands.add(btnAddContact, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
        btnRemoveContact = new JButton();
        btnRemoveContact.setEnabled(false);
        btnRemoveContact.setText("-");
        jpLeftCommands.add(btnRemoveContact, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
        btnCallContact = new JButton();
        btnCallContact.setEnabled(false);
        btnCallContact.setText("chiama contatto");
        jpLeftContent.add(btnCallContact, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
        btnGetMessages = new JButton();
        btnGetMessages.setText("ricevi tutti messaggi");
        jpLeftContent.add(btnGetMessages, new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
        jpAddContact = new JPanel();
        jpAddContact.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1));
        jpLeftContent.add(jpAddContact, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
        txtNewName = new JTextField();
        txtNewName.setText("");
        jpAddContact.add(txtNewName, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
        lbNewNumber = new JLabel();
        lbNewNumber.setText("Numero");
        jpAddContact.add(lbNewNumber, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
        lbNewName = new JLabel();
        lbNewName.setText("Nome");
        jpAddContact.add(lbNewName, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
        txtNewNumber = new JTextField();
        jpAddContact.add(txtNewNumber, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(20, -1), null, 0, false));
        jspContacts = new JScrollPane();
        jpLeftContent.add(jspContacts, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
        lstContacts = new JList();
        jspContacts.setViewportView(lstContacts);
        btnGetNewMessages = new JButton();
        btnGetNewMessages.setEnabled(false);
        btnGetNewMessages.setText("ricevi nuovi messaggi");
        jpLeftContent.add(btnGetNewMessages, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
        btnDelAllMessages = new JButton();
        btnDelAllMessages.setText("rimuovi tutti messaggi");
        jpLeftContent.add(btnDelAllMessages, new GridConstraints(8, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
        final JPanel panel2 = new JPanel();
        panel2.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1));
        jpLeftContent.add(panel2, new GridConstraints(7, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
        btnDeleteMessage = new JButton();
        btnDeleteMessage.setEnabled(true);
        btnDeleteMessage.setText("rimuovi messaggio");
        panel2.add(btnDeleteMessage, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
        txtMsgToRemove = new JTextField();
        panel2.add(txtMsgToRemove, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(50, -1), new Dimension(50, -1), 0, false));
        jpRightContent = new JPanel();
        jpRightContent.setLayout(new GridLayoutManager(4, 1, new Insets(0, 0, 0, 0), -1, -1));
        jpRightContent.setEnabled(false);
        splitPane1.setRightComponent(jpRightContent);
        lbRightTitle = new JLabel();
        lbRightTitle.setText("Messaggi");
        jpRightContent.add(lbRightTitle, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
        jspChat = new JScrollPane();
        jpRightContent.add(jspChat, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
        txtChat = new JTextArea();
        txtChat.setEditable(false);
        txtChat.setEnabled(true);
        jspChat.setViewportView(txtChat);
        jpRightCommands = new JPanel();
        jpRightCommands.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1));
        jpRightContent.add(jpRightCommands, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
        btnExit = new JButton();
        btnExit.setText("Esci");
        jpRightCommands.add(btnExit, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
        btnClearChatHistory = new JButton();
        btnClearChatHistory.setText("azzera chat");
        jpRightCommands.add(btnClearChatHistory, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
        final Spacer spacer1 = new Spacer();
        jpRightCommands.add(spacer1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false));
        jpChatCommands = new JPanel();
        jpChatCommands.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1));
        jpRightContent.add(jpChatCommands, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
        txtMessage = new JTextField();
        txtMessage.setEnabled(false);
        jpChatCommands.add(txtMessage, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
        btnSendMessage = new JButton();
        btnSendMessage.setEnabled(false);
        btnSendMessage.setText("invia msg");
        jpChatCommands.add(btnSendMessage, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
        btnCloseCall = new JButton();
        btnCloseCall.setEnabled(false);
        btnCloseCall.setText("fine");
        jpChatCommands.add(btnCloseCall, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    }

    /**
     * @noinspection ALL
     */
    public JComponent $$$getRootComponent$$$() {
        return panel1;
    }
}
